#include "cvolumesliderdlg.h"
#include <QVBoxLayout>
#include <QSlider>
#include <QLabel>

CVolumeSliderDlg::CVolumeSliderDlg(QWidget *parent) : QWidget(parent)
{
    this->setFixedSize(40,200);
    this->setWindowFlags(Qt::FramelessWindowHint | Qt::ToolTip);
    this->setStyleSheet("QDialog{background-color:rgba(54,54,54,0.5);}");
    QVBoxLayout* pVlay = new QVBoxLayout(this);
    m_pVolumeSlider = new QSlider(this);
    m_pVolumeSlider->setOrientation(Qt::Vertical);
    m_pVolumeSlider->setRange(0,100);
    m_progressLabel = new QLabel(this);
    m_progressLabel->setFixedSize(40,25);
    m_progressLabel->setAttribute(Qt::WA_TranslucentBackground);
    m_progressLabel->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
    m_progressLabel->setStyleSheet("QLabel { color : white;margin-bottom:15}");
    connect(m_pVolumeSlider,&QSlider::valueChanged,this,&CVolumeSliderDlg::volumeSlider_ValueChanged);
    //connect(m_pVolumeSlider,&QSlider::valueChanged,this,&CVolumeSliderDlg::volumeSlider_ValueChanged);
    //pVlay->addWidget(m_progressLabel);
    pVlay->addWidget(m_pVolumeSlider);

}


void CVolumeSliderDlg::setSliderValue(int value){
    //供外部使用
    m_pVolumeSlider->setValue(value);
}

void CVolumeSliderDlg::volumeSlider_ValueChanged(int value){
   emit sig_SliderValueChanged(value);
   QString strVol = QString("%1%").arg(value);
   m_progressLabel->setText(strVol);
}
